package com.burgeon.backend.SHOP.service.Impl;

import com.burgeon.backend.SHOP.rest.FindRECHARGE;
import com.burgeon.backend.SHOP.service.APPRechargerService;
import com.burgeon.backend.entity.Info;
import com.burgeon.backend.mappers.AccountMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;

@Service
public class APPRechargerServiceImpl implements APPRechargerService {
    @Autowired
    private AccountMapper accountMapper;

    @Override
    public HashMap findDataByVip(String vip, String token) {
        Info info = GetInfo(token);
        FindRECHARGE findRECHARGE = new FindRECHARGE(info.getUrl(), info.getAccount(), info.getPassword());

        try {
          return findRECHARGE.getData(vip);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    private Info GetInfo(String token) {
        return accountMapper.GetTokenData(token);
    }
}
